	package Model;

import java.util.ArrayList;
import java.util.Observable;

public class BusinessRuleManager extends Observable{

	private ArrayList<BusinessRule> businessRuleSelectList;
	private ArrayList<BusinessRule> businessRuleToGenerate;
	
	
	public BusinessRuleManager(){
		businessRuleSelectList = new ArrayList<BusinessRule>();
		businessRuleToGenerate = new ArrayList<BusinessRule>();
	}
	
	public void addBusinessRuleForSelecting(BusinessRule b){
		businessRuleSelectList.add(b);
	}
	
	public boolean SetToGenerate(BusinessRule b){
		if(businessRuleSelectList.remove(b)){
			businessRuleToGenerate.add(b);
			setChanged();
			notifyObservers();
			return true;
		}
		return false;	
	}
	
	public boolean RemoveFromGenerate(BusinessRule b){
		if(businessRuleToGenerate.remove(b)){
			businessRuleSelectList.add(b);
			setChanged();
			notifyObservers();
			return true;
		}
		return false;
	}
	
	public boolean SetAllToGenerate(){
		try{
			for(BusinessRule b : businessRuleSelectList){
				businessRuleToGenerate.add(b);
			}
			businessRuleSelectList.clear();
			setChanged();
			notifyObservers();
			return true;
		} catch (Exception e){
			e.printStackTrace();
			return false;
		}
	}
	
	public boolean SetAllToSelect(){
		try{
			for(BusinessRule b : businessRuleToGenerate){
				businessRuleSelectList.add(b);
			}
			businessRuleToGenerate.clear();
			setChanged();
			notifyObservers();
			return true;
		} catch(Exception e){
			e.printStackTrace();
			return false;
		}
	}
	
	public ArrayList<BusinessRule> getBusinessRuleList(){
		return businessRuleSelectList;
	}
	
	public ArrayList<BusinessRule> getBusinessToGenerate(){
		return businessRuleToGenerate;
	}	
	
	public int getListSizeSelectList() {
		return businessRuleSelectList.size();
	}
	
	public int getListSizeToGenerate(){
		return businessRuleToGenerate.size();
	}
	
}
